const mutations={
    changeName(state,name){
        state.name=name
    },
    //加入到购物车
    addToCart(state,product){
      console.log('购物商品修改');
      console.log(state.buyNums)
        let inCart = false;
        state.cart.forEach(el=>{
           if(el.id==product.id){
              el.num++
              inCart=true;
           }
        })
        if(!inCart){
          state.cart.push(product);
        }
        state.buyNums++;      
        console.log(state.buyNums,111);
    },
    makeMoney(state,payload){
        state.money = state.money+payload
    }
  };
  export default mutations;